package com.approval.approvalapp;

import android.app.Application;
import android.app.Service;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Vibrator;

import com.approval.approval.LocationService;
import com.approval.approvalapp.util.SpUtil;
import com.uuzuche.lib_zxing.activity.ZXingLibrary;

/**
 * Created by louyulin on 2019/3/26.
 */

public class MyAppliaction extends Application {
    private static MyAppliaction instance;
    public LocationService locationService;
//    public Vibrator mVibrator;
    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;

        locationService = new LocationService(getApplicationContext());
        ZXingLibrary.initDisplayOpinion(this);

    }

    public static MyAppliaction getInstance() {
        return instance;
    }

    //判断是否登录
    public boolean isLogin() {
        String string = SpUtil.getString(instance, SpUtil.USER_RUN_ID, "-1");
        if (string.equals("-1")){
            return false;
        }
        return true;
    }

    public PackageInfo getPackageInfo() {
        PackageInfo info = null;
        try {
            info = getPackageManager().getPackageInfo(getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace(System.err);
        }
        if (info == null)
            info = new PackageInfo();
        return info;
    }

}
